package cn.tedu.test;

import org.junit.jupiter.api.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import spring.pojo.Dept;
import spring.pojo.Emp;
import spring.pojo2.Courses;
import spring.pojo2.Teacher;

public class test_DI {
    @Test
    public void test1(){
        //di --把两个对象间的关系依赖注入
        Dept dept = new Dept();
        Emp emp = new Emp();
        Emp emp2 = new Emp();
        dept.setName("11");
        emp.setDept(dept);
        System.out.println(emp.getDept());
        System.out.println(emp2.getDept());
        System.out.println(dept);
        System.out.println(emp);
    }
    @Test
    public void test2(){
        ClassPathXmlApplicationContext spring_config =
                new ClassPathXmlApplicationContext("spring_config.xml");
        Teacher t = (Teacher)spring_config.getBean("teacher");
//        t.setName("小明");
        t.name = "xiao";

        System.out.println(t);
    }
}
